<template>
  <div class="app-container">
    <div class="page-filter mb10 fl">
      <el-form ref="filter" :model="filter" label-width="0">
        <el-form-item class="mr10 mb5 fl">
          <el-input v-model="filter.nickname" placeholder="姓名" size="small" clearable />
        </el-form-item>
        <el-form-item class="mr10 mb5 fl" style="width: 300px">
          <el-button size="small" @click="app.reset('filter')">清 空</el-button>
          <el-button type="primary" size="small" @click="getList">查 询</el-button>
        </el-form-item>
      </el-form>
    </div>
    <el-table v-loading="app.loading" class="search-table" :data="list" border fit highlight-current-row style="width: 100%;">
      <el-table-column label="序号" align="center" width="56px">
        <template slot-scope="{$index}">
          {{ $index + 1 }}
        </template>
      </el-table-column>
      <el-table-column label="姓名" width="120px" prop="nickname" />
      <el-table-column label="性别" align="center" width="80px" :formatter="formatter"/>
      <el-table-column label="出生日期" align="center" width="110px" prop="birthday" />
      <el-table-column label="身份证号" align="center" width="190px" prop="card" />
      <el-table-column label="入职日期" align="center" width="110px" prop="induction_time" />
      <el-table-column label="手机号码" align="center" width="120px" prop="phone" />
      <el-table-column label="状态" align="center" width="80px" :formatter="formatterState"/>
      <el-table-column label="备注" min-width="260px" prop="remark" />
      <el-table-column label="操作" align="center" width="90px" fixed="right">
        <template slot-scope="{row}">
          <el-dropdown>
            <el-button type="primary" size="mini">
              操作<i class="el-icon-arrow-down el-icon--right"></i>
            </el-button>
            <el-dropdown-menu slot="dropdown">
              <el-dropdown-item @click.native="handleDialog({dTitle: '工作报告查看权限', dType: '', dField: dField, su_id: row.id})">权 限</el-dropdown-item>
            </el-dropdown-menu>
          </el-dropdown>
        </template>
      </el-table-column>
    </el-table>
    <pagination v-show="filter.pageAll>0" :total="filter.pageAll" :page.sync="filter.pageCurrent" :limit.sync="filter.pageNumber" @pagination="getList" />
    <Dialog ref="dialog" :get-data="getList" :info="dialog" />
  </div>
</template>

<script>
import { queryStaffs } from '@/api/staff'
import Dialog from './components/disk/power-dialog'
import page from '@/utils/page'

export default {
  name: '',
  components: { Dialog },
  extends: page,
  props: {
    reqList: {
      default: queryStaffs,
      type: Function
    }
  },
  data() {
    return {
      dField: ['su_id']
    }
  },
  created() {
    this.getList()
  },
  methods: {
    formatter(e) {
      let sex = '-'
      switch (e.sex) {
        case 1:
          sex = '男'
          break;
        case 2:
          sex = '女'
          break;
        default:
          break;
      }
      return sex
    },
    formatterState(e) {
      let state = '-'
      switch (e.state) {
        case 0:
          state = '未转正'
          break;
        case 1:
          state = '已转正'
          break;
        case 2:
          state = '已离职'
          break;
        default:
          break;
      }
      return state
    }
  }
}
</script>
